package com.zrx.springboot.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrx.springboot.entity.Address;
import com.zrx.springboot.entity.BackOrder;
import com.zrx.springboot.entity.Order;
import com.zrx.springboot.entity.User;
import com.zrx.springboot.mapper.BackOrderMapper;
import com.zrx.springboot.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BackOrderServiceImpl implements BackOrderService {
    @Autowired
    private BackOrderMapper backOrderMapper;
    @Autowired
    private UserService userService;

    @Override
    public List<BackOrder> fianOederList() {
        List<User> list = userService.list();
        List<Integer> ids = new ArrayList<Integer>();
        for (User user : list) {
            ids.add(user.getId());
        }
        List<BackOrder> orderListByUser = backOrderMapper.findOrderListByUser(ids);


        return orderListByUser;
    }

    @Override
    public List<BackOrder> fianOedernameList(String ordername) {
        List<User> list = userService.list();
        List<Integer> ids = new ArrayList<Integer>();
        for (User user : list) {
            ids.add(user.getId());
        }
        List<BackOrder> orderListByUser = backOrderMapper.findOrderListByname(ordername,ids);


        return orderListByUser;
    }


}